﻿using System;
using System.Text;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Windows.Forms;
using QLTB.Controllers;
using DevComponents.DotNetBar;
using System.Collections.Generic;
using AF_ORM.CORE;
using DevComponents.DotNetBar.Controls;


namespace QuanLyThietBi.HamXuLy
{
     public class HamXuLy
    {
       
        public String LayChuoiSo(int AutoID)
        {
            if (AutoID < 10)
                return "00" + AutoID;
            else if (AutoID >= 10 && AutoID < 100)
                return "0" + AutoID;
            else if (AutoID >= 100 && AutoID < 1000)
                return "" + AutoID;
            else
                return "";
        }
       
        public int KiemTraBatDauKetThuc(DateTime bd, DateTime kt)
        {
            if (bd < kt)
            
                return 1;
            
            else
                return 0;
        }
        public string LayMaID(string sp)
        {
            SqlParameter[] param = new SqlParameter[1];
            //string sp = "P_GetMaNhomQL";
            param[0] = new SqlParameter("@ma", "");
            param[0].Direction = ParameterDirection.Output;
            param[0].DbType = DbType.String;
            param[0].Size = 10;
            SqlHelper.ExecuteNonQuery(Config.ConnectionConfig.ConnectionString, CommandType.StoredProcedure, sp, param);
            return param[0].Value.ToString();
        }

        public void LoadData(DataGridViewX DGV, BindingNavigator BN, DataTable dt)
        {
            BindingSource BS = new BindingSource();
            BS.DataSource = dt;
            BN.BindingSource = BS;
            DGV.DataSource = BS;
        }

       
    }

}